package com.yanxibao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yanxibao.bean.Collection;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


/**
 * 收藏;(_collection)表数据库访问层
 *
 * @author kongke
 * @date 2023/11/16
 */
@Mapper
public interface CollectionMapper extends BaseMapper<Collection> {

    @Update("update yxb_collection c , yxb_userinfo u set c.deleted = 1 , u.collection = u.collection - 1 where c.collection_id = #{cId} and u.user_id = #{uId}")
    Integer delCol(@Param("cId") Integer cId, @Param("uId") String uId);

    @Select("select * from yxb_collection where user_id =  #{uId} and um_id = #{umId} and deleted = 0")
    Collection isCol(@Param("uId") String uId , @Param("umId") Integer umId);

}